package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * <b>Project ChatSystemG6 INSA 4INFOA1 - 2013/2014</b>
 * <P>
 * <i>Package gui </i> <br>
 * AboutDialog is the the dialog window which is opened when the user want to know what this application is about
 * 
 * @author Christelle SIAGO HAPPI
 * 
 */

public class AboutDialog extends JDialog{

    private JButton closeButton;
    private JPanel  panel;
    private JLabel  label_appName,label_appBuild,label_author;
    private JLabel  label_email,label_framework,label_website;
   


    /**
     * create a dialog window
     * @param parent        the name of the frame which contains the window
     * @param appName       the name of the application
     * @param appVersion    the version of this application   
     * @param appBuild      the last update
     */
    public AboutDialog(JFrame parent, String appName, String appVersion, String appBuild)
    {
        super(parent,true);
        init(appName,appVersion,appBuild);
    }

    
    /**
     * initialize this dialog
          * @param appName       the name of the application
     * @param appVersion    the version of this application   
     * @param appBuild      the last update
     */
    private void init(String appName, String appVersion, String appBuild)
    {
      
        setTitle("About");
        setSize(220, 210);
        getContentPane().setLayout(new BorderLayout());
        setLocationRelativeTo(null);
        Font font = new Font("Cambria", Font.BOLD, 15);

        addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e)
            {dispose();}
        });

        panel = new JPanel();
        panel.setLayout(new FlowLayout());

        closeButton = new JButton("Close");
        closeButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            { dispose();}
        });

        label_appName = new JLabel(appName,null,SwingConstants.LEFT);
        label_appName.setFont(font);
        label_appName.setForeground(Color.RED);

        label_appBuild = new JLabel("version "+appVersion+"\n");
        label_appBuild.setFont(font);
        label_appBuild.setForeground(Color.RED);

        label_author = new JLabel("Christelle SIAGO HAPPI\n\n");
        label_author.setForeground(Color.BLUE);

        label_framework = new JLabel("Copyright (c) 2013 INSA Toulouse    \n");
        label_website = new JLabel("http://www.insa-toulouse.fr\n");
        label_email = new JLabel("siagohap@etud.insa-toulouse.fr\n\n");

        label_email.setForeground(Color.GRAY);
        label_framework.setForeground(Color.GRAY);
        label_website.setForeground(Color.GRAY);

        font = new Font(Font.DIALOG, Font.BOLD, 12);

        label_appName.setFont(font);
        label_appBuild.setFont(font);
        label_author.setFont(font);
        label_email.setFont(font);
        label_framework.setFont(font);
        label_website.setFont(font);



        panel.add(label_appName);
        panel.add(new JLabel(" "));
        panel.add(label_appBuild);
        panel.add(new JLabel(" "));
        panel.add(label_author);
        panel.add(new JLabel(" "));
        panel.add(label_email);
        panel.add(new JLabel(" "));
        panel.add(label_framework);
        panel.add(label_website);

        panel.add(new JLabel(" "));
        closeButton.setHorizontalTextPosition(SwingConstants.CENTER);
        panel.add(closeButton);

        getContentPane().add("Center", panel);
      }
}
